package gps
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.GeolocationEvent;
	import flash.sensors.Geolocation;

	public class GpsReceiver extends Geolocation
	{
		/* current user location*/
		private var m_currentLocation:GeolocationEvent = null;
		
		/**
		* GpsReceiver constructor
		*/
		public function GpsReceiver()
		{
			super();
			setRequestedUpdateInterval(1000);
		}
		/**
		* gets the current user location
		*/
		public function get getCurrentLocation():GeolocationEvent
		{
			return m_currentLocation;
		}
		/**
		* handles GeoLocationUpdate events
		*/
		private function onGeolocationUpdate(event:GeolocationEvent):void
		{
			m_currentLocation = event;
		}
		/**
		* starts the GpsService
		*/
		public function startGpsService():Boolean
		{
			if (!isSupported) 
			{
				return false;
			}
			addEventListener(GeolocationEvent.UPDATE,onGeolocationUpdate,false,0,true);
			return true;
		}
		/**
		* stops the GpsService
		*/
		public function stopGpsService():Boolean
		{
			if (!isSupported) 
			{
				return false;
			}
			removeEventListener(GeolocationEvent.UPDATE,onGeolocationUpdate,false);
			return true;
		}
	}
}